package com.punch.course.controller;

import com.punch.common.model.Result;
import com.punch.common.page.PageInfo;
import com.punch.common.vo.course.classes.AppCourseClassPageVO;
import com.punch.common.vo.course.classes.AppCourseClassVO;
import com.punch.common.vo.course.classes.FeignClassVO;
import com.punch.course.query.AppClassQueryInfo;
import com.punch.course.service.AppClassService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

/**
 * @className: AppClassController
 * @description: App端课程班级管理
 * @author: wujj
 * @date: 2020/12/07 15:14
 **/
@RestController
@Api(value = "AppClassController", tags = "App端课程班级管理Controller")
public class AppClassController {

    @Resource
    private AppClassService appClassService;

    /**
     * app学生可选课程列表
     *
     * @param studentId 学生id
     * @param queryInfo 查询条件
     * @return PageInfo<AppCourseClassPageVO>
     */
    @GetMapping(value = "/course/app/{studentId}/classes", produces = "application/json; charset=utf-8")
    @ApiOperation(value = "app学生可选课程列表", notes = "app学生可选课程列表", produces = "application/json")
    public Result<PageInfo<AppCourseClassPageVO>> listCourseClass(@PathVariable Long studentId,
                                                                  @ModelAttribute AppClassQueryInfo queryInfo) {
        return Result.succeed(appClassService.listCourseClass(studentId, queryInfo));
    }

    /**
     * 课程班级详情
     *
     * @param courseClassId 课程班级id
     * @param studentId     学生id
     * @return AppCourseClassVO
     */
    @GetMapping(value = "/course/app/class/{courseClassId}", produces = "application/json; charset=utf-8")
    @ApiOperation(value = "app端班级课程详情", notes = "app端班级课程详情", produces = "application/json")
    public Result<AppCourseClassVO> getCourseClassForApp(@PathVariable Long courseClassId, @RequestParam("studentId") Long studentId) {
        return Result.succeed(appClassService.getCourseClassForApp(courseClassId, studentId));
    }

    /**
     * 服务间调用查询班级详情
     *
     * @param courseClassId 班级记录id
     * @return FeignClassVO
     * @author wujj
     * @since 2020/7/14 10:51
     */
    @GetMapping(value = "/course/class/feign/{courseClassId}", produces = "application/json; charset=utf-8")
    public FeignClassVO getFeignClassById(@PathVariable("courseClassId") Long courseClassId) {
        return appClassService.getFeignClassById(courseClassId);
    }

}
